<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin: 0px;
            padding: 0px;
            list-style: none;
        }
        div{
            width: 780px;
            height: 366px;
            margin: 100px auto;
            background: url("pic1.jpg");
            position: relative;
        }
        h1{
            text-align: center;
            color: coral;
        }
        h2{
            margin-top: 120px;
            text-align: center;
            color: white;
        }
        button{
            position: absolute;
            background-color: coral;
            color: white;
            border: none;
            cursor: pointer;
            width: 100px;
            height: 50px;
            
        }
        button:nth-of-type(1){
            bottom: 80px;
            float: left;
        }
        button:nth-of-type(2){
            bottom: 10px;
            float: right;
        }
    </style>
</head>
<body>


    <div>
        <h1>抽奖</h1>
        <h2 id="txt">开始抽奖</h2>
        <button id="start">开始</button>
        <button id="end">结束</button>
    </div>


    <script>
        var txt = document.getElementById('txt');
        var start = document.getElementById('start');
        var end = document.getElementById('end');
        var person = ['阿毛','阿财','阿狗'];
        var time;
        start.onclick=function(){
            clearInterval(time);
            time=setInterval(function(){
                var num = parseInt(Math.random()*person.length);
                txt.innerHTML=person[num];
            },100)
        }
        end.onclick=function(){
            clearInterval(time);
        }
    </script>
</body>
</html>